package other.one.advance;

/**
 * 人员进入/退出房间的请求参数
 *
 * @author WangChenyu
 * @since 2024-04-18 08:07
 */
public class RoomRequest implements Comparable<RoomRequest> {

    private String userId;

    private String roomId;

    /**
     * 操作 1->进入房间 ，0->退出房间
     */
    private Integer type;
    /**
     * 序列号，从1开始，递增添加
     */
    private Integer serialNo;

    public static RoomRequest joinRoom(String userId, String roomId, Integer serialNo) {
        RoomRequest roomRequest = new RoomRequest(userId, roomId, serialNo);
        roomRequest.setType(1);
        return roomRequest;
    }

    public static RoomRequest leaveRoom(String userId, String roomId, Integer serialNo) {
        RoomRequest roomRequest = new RoomRequest(userId, roomId, serialNo);
        roomRequest.setType(0);
        return roomRequest;
    }


    public RoomRequest(String userId, String roomId, Integer serialNo) {
        this.userId = userId;
        this.roomId = roomId;
        this.serialNo = serialNo;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getRoomId() {
        return roomId;
    }

    public void setRoomId(String roomId) {
        this.roomId = roomId;
    }

    public Integer getSerialNo() {
        return serialNo;
    }

    public void setSerialNo(Integer serialNo) {
        this.serialNo = serialNo;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    @Override
    public int compareTo(RoomRequest o) {
        // 降序排列
        return Integer.compare(this.getSerialNo(), o.getSerialNo());
    }
}
